
*** Replication code for Hakansson: "Do women pay a higher price for power? Gender bias in political violence in Sweden"

*** 8 September, 2019

/* Important: 

Researchers can apply to access the PTU data from the Swedish National Council for Crime Prevention.
To obtain the PTU variables, replicators must gain permission. The code provided in this do file can be used to 
replicate the article's results once access to the PTU data has been obtained. 

The supplementary data from KOLFU is made available through dataverse. However, variables that could make
it possible to identify individuals are excluded. These variables are asterisked out in the analyses. See
more below. */

*******************************************************************************************************************
*******************************************************************************************************************

* ////////////////////////////
* // 		PTU DATA 		//
* ////////////////////////////

*******************************************************************************************************************
*******************************************************************************************************************



*******************************************************************************************************************
*******************************************************************************************************************

*		CODE RELEVANT VARIABLES

*******************************************************************************************************************
*******************************************************************************************************************

* /////////////////////////////////
* // PREPARING DATA SET PTU 2013 //
* /////////////////////////////////

* Single out municipal politicians
keep if F1_KOMMUN==1
rename F1_KOMMUN KommunF
rename F1_LANDSTING LandstingF
rename F1_RIKSDAG Riksdag

* year variable
gen year=2013
gen valar=2010
* gender variable
gen female=.
replace female=1 if KOeN==2
replace female=0 if KOeN==1
label define female 1 "women" 0 "men"
label values female female
drop KOeN

* party variable
gen party=.
replace party =1 if partitillhoerighet==5
replace party =2 if partitillhoerighet==2 
replace party =3 if partitillhoerighet==6
replace party =4 if partitillhoerighet==4 
replace party =5 if partitillhoerighet==7
replace party =6 if partitillhoerighet==3 
replace party =7 if partitillhoerighet==1
replace party =8 if partitillhoerighet==8
replace party =9 if party==.

label define party 1 "v" 2 "s" 3 "mp" 4 "c" 5 "kd" 6 "l" 7 "m" 8 "sd" 9 "other" 
label values party party

drop partitillhoerighet
drop Parti

* rename variables and drop irrelevant variables to harmonize to other waves
rename F73_01 G73_01
rename F73_02 G73_02
rename F73_03 G73_03
rename F73_04 G73_04
rename F73_05 G73_05

drop Vikt NUTS2 NUTS1 Kommun f22psum

rename Tilltradesdatum Tilltraedesdatum
rename Lan Laen
rename Valomradesnamn Valomraadesnamn
rename F1_antalpolfoersaml antalpolfoersaml
rename POLISMYNDIG POLISREGION
rename F4_Fullmaektige Fullmaektige
rename F4_Styrelse Styrelse
rename F4_Haelso_sjuk Haelso_sjuk
rename F4_Kultur_fritid Kultur_fritid
rename F4_Plan_bygg Plan_bygg
rename F4_Social Social
rename F4_Teknisk Teknisk
rename F4_Utbildning Utbildning
rename F4_Annan1 Annan1
rename F4_Annan2 Annan2
rename F4_Annan3 Annan3
rename F4_ANTALUPPDRAG ANTALUPPDRAG
rename F4_Ordfoerande Ordfoerande
rename F4_Foerstevordf Foerstevordf
rename F4_Ord_ledamot Ord_ledamot
rename F4_Ersaettare Ersaettare
rename F8_bakgrund BAKGRUND
rename antalpolfoersaml antalpolfoersaml2

* save new data set
save "C:Data\PTU13 ready for append.dta"


* /////////////////////////////////
* // PREPARING DATA SET PTU 2015 //
* /////////////////////////////////

*single out municipal politicians
keep if KommunF==1

*add year variable
gen year=2015
gen valar=2014

* gender variable
gen female=.
replace female=1 if KOeN==2
replace female=0 if KOeN==1
label define female 1 "women" 0 "men"
label values female female

drop KOeN

* Party
gen party=.
replace party =1 if Parti==5
replace party =2 if Parti==2 
replace party =3 if Parti==55 
replace party =4 if Parti==4 
replace party =5 if Parti==68 
replace party =6 if Parti==3 
replace party =7 if Parti==1
replace party =8 if Parti==110 
replace party =9 if party==.

label define party 1 "v" 2 "s" 3 "mp" 4 "c" 5 "kd" 6 "l" 7 "m" 8 "sd" 9 "other" 
label values party party

drop Parti
rename Parti_beteckning Parti_beteckn

* rename variables and drop irrelevant variables to harmonize to other waves
drop filter Politik Kommun
rename Inmedium InMedium
destring SCBid, replace
destring Foedelseaar, replace
destring Laen, replace

* save new data set
save "C:Data\PTU15 ready for append.dta"

* /////////////////////////////////
* // PREPARING DATA SET PTU 2015 //
* /////////////////////////////////

keep if KommunF==1

*add year variable
gen year=2017
gen valar=2014

* gender
encode Kon_numerisk, generate(Kon_numerisk2)
drop Kon_numerisk
rename Kon_numerisk2 Kon_numerisk

gen female=.
replace female=1 if Kon_numerisk==2
replace female=0 if Kon_numerisk==1
label define female 1 "women" 0 "men"
label values female female

drop KOeN Kon_numerisk

* Party
gen party=.
replace party =1 if partitillhoerighet==5
replace party =2 if partitillhoerighet==2 
replace party =3 if partitillhoerighet==6
replace party =4 if partitillhoerighet==4 
replace party =5 if partitillhoerighet==7
replace party =6 if partitillhoerighet==3 
replace party =7 if partitillhoerighet==1
replace party =8 if partitillhoerighet==8
replace party =9 if party==.

label define party 1 "v" 2 "s" 3 "mp" 4 "c" 5 "kd" 6 "l" 7 "m" 8 "sd" 9 "other" 
label values party party

rename PARTI_BETECKN Parti_beteckn

* rename variables and drop irrelevant variables to harmonize to other waves
drop FodA politik KOMMUNNUMMER kommunkod
rename TILLTRAeDE_VALDAG Tilltraedesdatum
rename Lan Laen
rename VALTYP Valtyp
rename VALTYP2 Valtyp2
rename VALTYP3 Valtyp3
rename Kommun kommunkod
destring SCBid, replace
destring Laen, replace

* save new data set
save "C:Data\PTU17 ready for append.dta"

* /////////////////////////////////
* // MERGING THE THREE DATA SETS //
* /////////////////////////////////

use "C:Data\PTU13 ready for append.dta", clear
append using "C:Data\PTU15 ready for append.dta"
append using "C:Data\PTU17 ready for append.dta"

* /////////////////////////////////
* // CODING VARIABLES, CONTINUED //
* /////////////////////////////////

*************************** POLITICIANS' POSITION ******************************

*	1. Policy committees

* health and healthcare
gen health_com=.
replace health_com=1 if F4_03==1 | F4_03==2 | F4_03==3 | F4_03==4
*culture and leisure	
gen cult_leis_com=.
replace cult_leis_com =1 if F4_04==1 | F4_04==2 | F4_04==3 | F4_04==4
*planning and building
gen plan_build_com=.
replace plan_build_com=1 if F4_05==1 | F4_05==2 | F4_05==3 | F4_05==4 
*social
gen soc_com=.
replace soc_com=1 if F4_06==1 | F4_06==2 | F4_06==3 | F4_06==4 
*technical
gen tec_com=.
replace tec_com=1 if F4_07==1 | F4_07==2 | F4_07==3 | F4_07==4
*education
gen edu_com=.
replace edu_com=1 if F4_08==1 | F4_08==2 | F4_08==3 | F4_08==4
*other
gen other_com=.
replace other_com=1 if F4_09==1 | F4_09==2 | F4_09==3 | F4_09==4 | F4_10==1 | ///
 F4_10==2 | F4_10==3 | F4_10==4 | F4_11==1 | F4_11==2 | F4_11==3 | F4_11==4

replace health_com=0 if health_com==.
replace cult_leis_com=0 if cult_leis_com==.
replace plan_build_com=0 if plan_build_com==.
replace soc_com=0 if soc_com==.
replace tec_com=0 if tec_com==.
replace edu_com=0 if edu_com==.
replace other_com=0 if other_com==.

*dummies for each committee
gen c_member=.
replace c_member = 1 if health_com==1
replace c_member =2 if cult_leis_com==1
replace c_member =3 if plan_build_com==1
replace c_member =4 if soc_com==1
replace c_member =5 if tec_com==1
replace c_member =6 if edu_com==1
replace c_member =7 if other_com==1

label variable c_member "Committee members"
label define c_member 1 "Health and healthcare" 2 "Culture and Leisure" 3 "Planning and Building" 4 "Social" 5 "Tecnical" 6 "Education" 7 "Other"
label values c_member c_member

*	2. Level of power

*	2.a 3 levels of power
gen level_of_power=.
*rank and file
replace level_of_power=1 if level_of_power==.
*committee chair
replace level_of_power=2 if F4_01==1 | F4_03==1 | F4_04==1 | F4_05==1 | F4_06==1 | F4_07==1 | F4_08==1 | F4_09==1 | F4_10==1 | F4_11==1
*mayor
replace level_of_power=3 if F4_02==1

label define level_of_power 1 "rankfile" 2 "committee or assembly chair" 3 "mayor"
label values level_of_power level_of_power

*	2.b mutually exclusive dummies for each level of power
gen l_rankfile=1 if level==1
replace l_rankfile=0 if l_rankfile==.
gen l_chair=1 if level==2
replace l_chair=0 if l_chair==.
gen l_mayor=1 if level==3
replace l_mayor=0 if l_mayor==.

* Make sure only true mayors are coded as mayors by dropping illogical observations. 
* Drop respondents that have both marked that they are mayors and that they only 
* work as politicians on their spare time
drop if l_mayor==1 & employment==1
* Drop observations that do not correspond to the municipality's information 
* on the party and gender of the mayor
drop if SCBid == 1607980768	| SCBid	== 1409722228 | SCBid	==	130049612 | SCBid == 1607998364 | SCBid == 1300490651 | SCBid	== 13004111590 | SCBid	==	14097114293	| SCBid	==	1300461975	| SCBid	==	1607968409	| SCBid	==	1409727615	| SCBid	==	1607913009	| SCBid	==	1409744966	| SCBid	==	160791323

*	3. Number of committees
gen sum_committees = health + cult + plan + soc +tec + edu + other

*	4. RIGHT vs. LEFT politicians

gen right_wing =0
replace right_wing=1 if party==4 | party==5 | party==6| party==7

gen left_wing=0
replace left_wing=1 if party==1 | party==2 | party==3



******************************* VIOLENCE ***************************************

*	1. VIOLENCE PREVIOUS YEAR, EACH FORM

rename F13_01 pyear_severe_phy_violence
rename F13_02 pyear_moderate_phy_violence
rename F13_03 pyear_weapon_violence
rename F13_04 pyear_arson
rename F13_05 pyear_graffiti
rename F13_06 pyear_theft
rename F13_07 pyear_other_damage
rename F13_08 pyear_other_phy_violence

rename F38_01 pyear_threat_verbal
rename F38_02 pyear_threat_phone
rename F38_03 pyear_threat_text
rename F38_04 pyear_threat_mail
rename F38_05 pyear_threat_email
rename F38_06 py_attack_social_media
rename F38_07 pyear_hijacked_account
rename F38_08 pyear_online_libel
rename F38_09 pyear_poster_pamphlet_libel
rename F38_10 pyear_undesired_order
rename F38_11 pyear_threat_gift
rename F38_12 pyear_unsolicited_photo_record
rename F38_13 pyear_stalking
rename F38_14 pyear_falsely_denounced
rename F38_15 pyear_threat_other

replace	pyear_severe_phy_violence =0 if	pyear_severe_phy_violence ==.
replace	pyear_moderate_phy_violence =0 if	pyear_moderate_phy_violence ==.
replace	pyear_weapon_violence =0 if	pyear_weapon_violence==.
replace	pyear_arson =0 if	pyear_arson==.
replace	pyear_graffiti =0 if	pyear_graffiti==.
replace	pyear_theft =0 if	pyear_theft==.
replace	pyear_other_damage =0 if	pyear_other_damage==.
replace	pyear_other_phy_violence =0 if	pyear_other_phy_violence==.
			
replace	pyear_threat_verbal	=0 if	pyear_threat_verbal==.
replace	pyear_threat_phone	=0 if	pyear_threat_phone==.
replace	pyear_threat_text	=0 if	pyear_threat_text==.
replace	pyear_threat_mail=0	if	pyear_threat_mail==.
replace	pyear_threat_email=0	if	pyear_threat_email==.
replace	py_attack_social_media=0	if	py_attack_social_media==.
replace	pyear_hijacked_account=0	if	pyear_hijacked_account==.
replace	pyear_online_libel=0	if	pyear_online_libel==.
replace	pyear_poster_pamphlet_libel=0	if	pyear_poster_pamphlet_libel==.
replace	pyear_undesired_order=0	if	pyear_undesired_order==.
replace	pyear_threat_gift=0	if	pyear_threat_gift==.
replace	pyear_unsolicited_photo_record=0	if	pyear_unsolicited_photo_record==.
replace	pyear_stalking=0	if	pyear_stalking==.
replace	pyear_falsely_denounced=0	if	pyear_falsely_denounced==.
replace	pyear_threat_other=0	if	pyear_threat_other==.

*	2. Any violence previous year, includes all violence types 
gen violence_pyear=.
replace violence_pyear=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 ///
 |pyear_weapon_violence==1 |pyear_arson==1 |pyear_graffiti==1 | pyear_theft ==1  ///
 |pyear_other_damage==1 |pyear_other_phy_violence==1 | pyear_threat_verbal==1 | ///
 pyear_threat_phone==1|pyear_threat_text==1|pyear_threat_mail==1|pyear_threat_email==1| ///
 pyear_stalking==1|pyear_threat_gift==1|pyear_threat_other==1|py_attack_social_media==1 | ///
 pyear_hijacked_account==1| pyear_online_libel==1 | pyear_poster_pamphlet_libel==1| ///
 pyear_undesired_order==1 | pyear_unsolicited_photo_record==1| pyear_falsely_denounced==1
replace violence_pyear=0 if violence_pyear==.

*	3. SUBTYPES VIOLENCE PREVIOUS YEAR

*	3a. five categories

gen py_bodily=.
replace py_bodily=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 | pyear_weapon_violence==1| pyear_other_phy_violence==1
replace py_bodily=0 if py_bodily==.
gen py_damage=.
replace py_damage=1 if pyear_arson==1| pyear_graffiti==1| pyear_other_damage==1 | pyear_theft==1 | pyear_undesired_order==1
replace py_damage=0 if py_damage==.
gen py_threat=.
replace py_threat=1 if pyear_threat_verbal==1 | pyear_threat_phone==1 | pyear_threat_text==1| ///
 pyear_threat_mail==1|pyear_threat_email==1|pyear_threat_gift==1|pyear_threat_other==1
replace py_threat=0 if py_threat==.
gen py_character_assassination=.
replace py_character_assassination=1 if pyear_hijacked_account==1| pyear_online_libel==1 | pyear_poster_pamphlet_libel==1
replace py_character_assassination=0 if py_character_assassination==.
gen py_harassment=.
replace py_harassment=1 if pyear_unsolicited_photo_record==1| pyear_stalking==1|pyear_falsely_denounced==1
replace py_harassment=0 if py_harassment==.

*	3b. CONTACT VIOLENCE
* Includes verbal, phone, text, mail, email, social media, physical, moderate physical, weapon
gen py_contact_violence=.
replace py_contact_violence=1 if pyear_threat_verbal==1| pyear_threat_phone==1| pyear_threat_text==1| ///
 pyear_threat_mail==1| pyear_threat_email==1| py_attack_social_media==1| pyear_severe_phy_violence==1| ///
 pyear_moderate_phy_violence==1|pyear_weapon_violence==1
replace py_contact_violence=0 if py_contact_violence ==.

*	3c. 2 categories: physical and psychologial violence
gen py_main_phy_violence=.
replace py_main_phy_violence=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 ///
| pyear_weapon_violence==1| pyear_other_phy_violence==1 | pyear_arson==1 | pyear_other_damage==1
replace py_main_phy_violence=0 if py_main_phy_violence==.
gen py_main_psy_violence=.
replace py_main_psy_violence=1 if  pyear_graffiti==1|  pyear_theft==1 |  pyear_threat_verbal==1 ///
 | pyear_threat_phone ==1 | pyear_threat_text ==1| pyear_threat_mail ==1| pyear_threat_email==1| ///
 py_attack_social_media==1 | pyear_hijacked_account ==1 | pyear_online_libel ==1 | ///
 pyear_poster_pamphlet_libel==1 | pyear_undesired_order==1 | pyear_threat_gift ==1| ///
 pyear_unsolicited_photo_record ==1 | pyear_stalking==1 | pyear_falsely_denounced ==1| pyear_threat_other==1
replace py_main_psy_violence=0 if py_main_psy_violence==.

*	4. Number of violence incidents previous year
recode F14 9999=.
recode F39 9999=.
replace F14=0 if F14==.
replace F39=0 if F39==.

gen times_violence_py = F14 + F39
gen times60_violence = F14 + F39
replace times60_violence =. if (times60_violence>60)

*	5. Number of violence forms experienced previous year
gen forms_violence=pyear_severe_phy_violence + pyear_moderate_phy_violence + pyear_weapon_violence ///
+ pyear_arson + pyear_graffiti+ pyear_theft + pyear_other_damage + pyear_other_phy_violence+ ///
 pyear_threat_verbal+ pyear_threat_phone+ pyear_threat_text+ pyear_threat_mail+ pyear_threat_email ///
 + py_attack_social_media+ pyear_hijacked_account+ pyear_online_libel+ pyear_poster_pamphlet_libel+ ///
 pyear_undesired_order+ pyear_threat_gift+ pyear_unsolicited_photo_record+ pyear_stalking+ ///
 pyear_falsely_denounced+ pyear_threat_other

  
****************************** PERPETRATORS ************************************
* 1. Perpetrator cateogry individuals

gen	perp_aggravated_citizen	=	0			
replace	perp_aggravated_citizen=1	if	F44==	1	| F21==	1				
						
gen	perp_own_party	=	0			
replace	perp_own_party=1	if	F44==	2	| F21==	2
						
gen	perp_other_party	=	0			
replace	perp_other_party=1	if	F44==	3	| F21==	3
						
gen	perp_business_owner	=	0			
replace	perp_business_owner=1	if	F44==	4	| F21==	4
						
gen	perp_querulant	=	0			
replace	perp_querulant=1	if	F44==	5	| F21==	5
						
gen	perp_other	=	0			
replace	perp_other=1	if	F44==	6	| F21==	6
						
gen	perp_dontknow	=	0			
replace	perp_dontknow=1	if	F44==	7	| F21==	7

*	2. Perpetrator group categories

gen	perp_antifeminist_member	=	0			
replace	perp_antifeminist_member=1	if	F45==	1	| F22==	1
						
gen	perp_rightw_racist_extr_member	=	0			
replace	perp_rightw_racist_extr_member=1	if	F45==	2	| F22==	2
						
gen	perp_introrg_member	=	0			
replace	perp_introrg_member=1	if	F45==	3	| F22==	3
						
gen	perp_criminal_group_member	=	0			
replace	perp_criminal_group_member=1	if	F45==	4	| F22==	4
						
gen	perp_local_actiongrp_member	=	0			
replace	perp_local_actiongrp_member=1	if	F45==	5	| F22==	5
						
gen	perp_envir_animal_group_member	=	0			
replace	perp_envir_animal_group_member=1	if	F45==	6	| F22==	6
						
gen	perp_leftextremist_member	=	0			
replace	perp_leftextremist_member=1	if	F45==	7	| F22==	7
						
gen	perp_member_dontknow	=	0			
replace	perp_member_dontknow=1	if	F45==	7	| F22==	9

*************************** MECHANISMS AND *************************************
*************************** INDIVIDUAL CHARACTERISTICS *************************

*	1. Media attention
gen media_attention=.
replace media_attention= 1 if F5==5
replace media_attention= 2 if F5==4
replace media_attention =3 if F5==3
replace media_attention=4 if F5==2
replace media_attention=5 if F5==1

*	2. Intersectionality

* Foreign background
gen foreign_born= 1 if F8==4
replace foreign_born=1 if N1==2
replace foreign_born=0 if F8==1 | F8==2 | F8==3
replace foreign_born=0 if N1==1

gen parents_foreign_born=1 if F8==3
replace parents_foreign =1 if F8==2
replace parents_foreign=0 if F8==1
replace parents_foreign=1 if N2==2
replace parents_foreign=1 if N2==3
replace parents_foreign=0 if N2==1

gen foreign_background=0 if foreign_born==0
replace foreign_background=0 if parents_f==0
replace foreign_background=1 if foreign_born==1 
replace foreign_background=1 if parents_foreign_born==1

* Age
gen young=1 if aalder<35
replace young=1 if aalder==35
replace young=0 if aalder>35

gen older=1 if aalder>59
replace older=1 if aalder==59
replace older=0 if aalder<59

* LBTQ
gen motive_sexual_minority=1 if G73_04==1
replace motive_sexual_min=1 if G73_02==1 
replace motive_sexual_minority=1 if F73_03==1
replace motive_sexual_min=1 if F73_04==1 
replace motive_sexual_min=0 if motive_sexual_min==.

* Experience: newcomer
* definition: everything up to "not more than 5 years" for the waves in between election years
* 1 year or less for election year wave
gen newcomer =1 if F2 ==1 
replace newcomer=1 if F2==2 & year==2013
replace newcomer =1 if F2==2 & year==2017
replace newcomer=1 if F2==3 & year==2013
replace newcomer =1 if F2==3 & year==2017
replace newcomer=0 if newcomer==.

* Active on social media
gen active_socialmedia=4 if F6==1
replace active_socialmedia=3 if F6==2
replace active_socialmedia=2 if F6==3
replace active_socialmedia=1 if F6==4
replace active_socialmedia=0 if F6==5

label define active_socialmedia 4 "very much" 3 "pretty much" 2 "not so much" 1 "very little" 0 "not at all"
label values active_socialmedia active_socialmedia


* /////////////////////////////////
* // ADD MUNICIPALITY VARIABLES //
* /////////////////////////////////

destring kommunkod, replace
sort valar

* Swedish registry data variables from Statistics Sweden

joinby valar kommunkod party using "H:Data\municipality variables.dta", unmatched(master)

**************** VARIABLES FOR FE AND CLUSTERED STANDARD ERRORS ****************

egen kommun_level = group(kommunkod level)
egen mean_wmayor_level = group(mean_wmayor level)

*******************************************************************************************************************
*******************************************************************************************************************

*		ANALYSES

*******************************************************************************************************************
*******************************************************************************************************************

* Equation 1
xi:reg violence_p female, cluster(kommunkod)
xi:reg violence_p female i.party, cluster(kommunkod)
xi:reg violence_p female i.party i.year, cluster(kommunkod)
xi:areg violence_p female i.party i.year, abs(kommunkod) cluster(kommunkod)
xi:areg violence female i.party i.year young foreign_back ///
newcomer motive_sexual_minority active_socialmedia, abs(kommunkod) cluster(kommunkod)

* Equation 2
xi:reg violence_p c.female##c.l_chair c.female##c.l_mayor, cluster(kommunkod)
xi:reg violence_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor, cluster(kommunkod)
xi:reg violence_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, cluster(kommunkod)
xi:areg violence_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
xi:areg violence c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor ///
i.foreign_back*l_chair i.foreign_back*l_mayor ///
i.newcomer*l_chair i.newcomer*l_mayor ///
i.motive_sexual_minority*l_chair i.motive_sexual_minority*l_mayor ///
i.young*l_chair i.young*l_mayor ///
i.active*l_chair i.active*l_mayor ///
, abs(kommun_level) cluster(kommunkod)


* Equation 1 in split sample per hierarchical level including individual level controls

* split sample per level of power, 
* first main model: fe for party, year, municipality
* second with controls for foreign background, newcomer, sexual minority motive, young, active social media
xi:areg violence female i.party i.year if l_r==1, abs(kommunkod) cl(kommunkod)
xi:areg violence female foreign_back newcomer motive_sex young active i.party i.year if l_r==1, abs(kommunkod) cl(kommunkod)
xi:areg violence female i.party i.year if l_c==1, abs(kommunkod) cl(kommunkod)
xi:areg violence female foreign_back newcomer motive_sex young active i.party i.year if l_c==1, abs(kommunkod) cl(kommunkod)
xi:areg violence female i.party i.year if l_m==1, abs(kommunkod) cl(kommunkod)
xi:areg violence female foreign_back newcomer motive_sex young active i.party i.year if l_m==1, abs(kommunkod) cl(kommunkod)
xi:reg violence female foreign_back newcomer motive_sex young active i.party i.year if l_m==1, cl(kommunkod) 


* ////////////////////////////
* //     VIOLENCE FORMS     //
* ////////////////////////////

*	1. Physical and psychological
*	PHYSICAL
reg py_main_phy_violence female, cluster(kommunkod)
xi:reg py_main_phy_violence female i.party, cluster(kommunkod)
xi:reg py_main_phy_violence female i.party i.year, cluster(kommunkod)
xi:areg py_main_phy_violence female i.party i.year, abs(kommunkod) cluster(kommunkod)

*	PSYCHOLOGICAL
reg py_main_psy_violence female, cluster(kommunkod)
xi:reg py_main_psy_violence female i.party, cluster(kommunkod)
xi:reg py_main_psy_violence female i.party i.year, cluster(kommunkod)
xi:areg py_main_psy_violence female i.party i.year, abs(kommunkod) cluster(kommunkod)

*	2. Five forms of violence

*	Eq 1
* bodily violence (punch, kick or similar; push or similar; weapon violence; other physical violence)
xi:areg py_bodily female i.party i.year, abs(kommunkod) cluster(kommunkod)
* economic (arson, grafiti, theft, undesired order, other damage)
xi:areg py_damage female i.party i.year, abs(kommunkod) cluster(kommunkod)
* threat (all threats)
xi:areg py_threat female i.party i.year, abs(kommunkod) cluster(kommunkod)
* harassment (stalking, unsolicited photo/recording, falsely denounced)
xi:areg py_harassment female i.party i.year, abs(kommunkod) cluster(kommunkod)
* symbolic (libel online, libel poster/pamphlet, hijacked account)
xi:areg py_character_assassination female i.party i.year, abs(kommunkod) cluster(kommunkod)


* Eq 2

* bodily violence (punch, kick or similar; push or similar; weapon violence; other physical violence)
xi:areg py_bodily c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
* economic (arson, grafiti, theft, undesired order, other damage)
xi:areg py_damage c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
* 3 threat (all threats)
xi:areg py_threat c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
* 4 harassment (stalking, unsolicited photo/recording, falsely denounced)
xi:areg py_harassment c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
* symbolic (libel online, libel poster/pamphlet, hijacked account)
xi:areg py_character_assassination c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)


*	3. Other subforms of violence
* contact violence
reg py_contact_violence c.female##c.l_chair c.female##c.l_mayor, cluster(kommunkod)
xi:reg py_contact_violence c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor, cluster(kommunkod)
xi:reg py_contact_violence c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, cluster(kommunkod)
xi:areg py_contact_violence c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)


* //////////////////////////
* // SENSITIVITY ANALYSES //
* //////////////////////////

*	1. Count definition of dependent variable: Number of violence incidents

* Zinb
xi:zinb times60_violence c.female##c.l_chair c.female##c.l_mayor ///
i.party*l_chair i.party*l_mayor i.year*l_chair i.year*l_mayor, inflate(c.female##c.l_chair c.female##c.l_mayor ///
i.party*l_chair i.party*l_mayor i.year*l_chair i.year*l_mayor) cl(kommunkod) irr
* Negative binomial
xi:nbreg times_violence c.female##c.l_chair c.female##c.l_mayor ///
i.party*l_chair i.party*l_mayor if times_v<60, cluster(kommunkod) irr
*OLS
xi:reg times60_violence c.female##c.l_chair c.female##c.l_mayor ///
i.party*l_chair i.party*l_mayor i.year*l_chair i.year*l_mayor, cl(kommunkod)

*	2. Count: Number of violence forms

* Zinb
xi:zinb forms_violence female ///
i.party i.year, inflate(female ///
i.party i.year) cl(kommunkod) irr
* Negative binomial
xi:nbreg forms_v female i.party i.year, cluster(kommunkod) irr
* OLS
xi:reg forms_violence female i.party i.year, cl(kommunkod)

*	3. SENSITIVITY TO EXCLUDING SPECIFIC VIOLENCE FORMS

* Generate violence variable where each form containing at least 100 incidents in one of 
* the waves is excluded

/*
The following have >100 in one of the years
pyear_stalking
pyear_threat_mail
pyear_threat_text
pyear_other_damage
pyear_moderate_phy_violence
pyear_threat_other
pyear_unsolicited_photo_record
pyear_online_libel 
py_attack_social_media 
pyear_threat_email
pyear_threat_phone
pyear_threat_verbal
*/

gen violence24_pyear=.
replace violence24_pyear=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 |pyear_weapon_violence==1 |pyear_arson==1 |pyear_graffiti==1 | pyear_theft ==1  |pyear_other_damage==1 |pyear_other_phy_violence==1 | pyear_threat_phone==1|pyear_threat_text==1|pyear_threat_mail==1|pyear_threat_email==1|pyear_stalking==1|pyear_threat_gift==1|pyear_threat_other==1|py_attack_social_media==1 | pyear_hijacked_account==1| pyear_online_libel==1 | pyear_poster_pamphlet_libel==1| pyear_undesired_order==1 | pyear_unsolicited_photo_record==1| pyear_falsely_denounced==1
replace violence24_pyear=0 if violence24_pyear==.

gen violence23_pyear=.
replace violence23_pyear=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 |pyear_weapon_violence==1 |pyear_arson==1 |pyear_graffiti==1 | pyear_theft ==1  |pyear_other_damage==1 |pyear_other_phy_violence==1 | pyear_threat_verbal==1 | pyear_threat_text==1|pyear_threat_mail==1|pyear_threat_email==1|pyear_stalking==1|pyear_threat_gift==1|pyear_threat_other==1|py_attack_social_media==1 | pyear_hijacked_account==1| pyear_online_libel==1 | pyear_poster_pamphlet_libel==1| pyear_undesired_order==1 | pyear_unsolicited_photo_record==1| pyear_falsely_denounced==1
replace violence23_pyear=0 if violence23_pyear==.

gen violence22_pyear=.
replace violence22_pyear=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 |pyear_weapon_violence==1 |pyear_arson==1 |pyear_graffiti==1 | pyear_theft ==1  |pyear_other_damage==1 |pyear_other_phy_violence==1 | pyear_threat_verbal==1 | pyear_threat_phone==1|pyear_threat_text==1|pyear_threat_mail==1| pyear_stalking==1|pyear_threat_gift==1|pyear_threat_other==1|py_attack_social_media==1 | pyear_hijacked_account==1| pyear_online_libel==1 | pyear_poster_pamphlet_libel==1| pyear_undesired_order==1 | pyear_unsolicited_photo_record==1| pyear_falsely_denounced==1
replace violence22_pyear=0 if violence22_pyear==.

gen violence21_pyear=.
replace violence21_pyear=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 |pyear_weapon_violence==1 |pyear_arson==1 |pyear_graffiti==1 | pyear_theft ==1  |pyear_other_damage==1 |pyear_other_phy_violence==1 | pyear_threat_verbal==1 | pyear_threat_phone==1|pyear_threat_text==1|pyear_threat_mail==1|pyear_threat_email==1|pyear_stalking==1|pyear_threat_gift==1|pyear_threat_other==1| pyear_hijacked_account==1| pyear_online_libel==1 | pyear_poster_pamphlet_libel==1| pyear_undesired_order==1 | pyear_unsolicited_photo_record==1| pyear_falsely_denounced==1
replace violence21_pyear=0 if violence21_pyear==.

gen violence9_pyear=.
replace violence9_pyear=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 |pyear_weapon_violence==1 |pyear_arson==1 |pyear_graffiti==1 | pyear_theft ==1  |pyear_other_damage==1 |pyear_other_phy_violence==1 | pyear_threat_verbal==1 | pyear_threat_phone==1|pyear_threat_text==1|pyear_threat_mail==1|pyear_threat_email==1|pyear_stalking==1|pyear_threat_gift==1|pyear_threat_other==1|py_attack_social_media==1 | pyear_hijacked_account==1| pyear_poster_pamphlet_libel==1| pyear_undesired_order==1 | pyear_unsolicited_photo_record==1| pyear_falsely_denounced==1
replace violence9_pyear=0 if violence9_pyear==.

gen violence8_pyear=.
replace violence8_pyear=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 |pyear_weapon_violence==1 |pyear_arson==1 |pyear_graffiti==1 | pyear_theft ==1  |pyear_other_damage==1 |pyear_other_phy_violence==1 | pyear_threat_verbal==1 | pyear_threat_phone==1|pyear_threat_text==1|pyear_threat_mail==1|pyear_threat_email==1|pyear_stalking==1|pyear_threat_gift==1|pyear_threat_other==1|py_attack_social_media==1 | pyear_hijacked_account==1| pyear_online_libel==1 | pyear_poster_pamphlet_libel==1| pyear_undesired_order==1 | pyear_falsely_denounced==1
replace violence8_pyear=0 if violence8_pyear==.

gen violence7_pyear=.
replace violence7_pyear=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 |pyear_weapon_violence==1 |pyear_arson==1 |pyear_graffiti==1 | pyear_theft ==1  |pyear_other_damage==1 |pyear_other_phy_violence==1 | pyear_threat_verbal==1 | pyear_threat_phone==1|pyear_threat_text==1|pyear_threat_mail==1|pyear_threat_email==1|pyear_stalking==1|pyear_threat_gift==1| py_attack_social_media==1 | pyear_hijacked_account==1| pyear_online_libel==1 | pyear_poster_pamphlet_libel==1| pyear_undesired_order==1 | pyear_unsolicited_photo_record==1| pyear_falsely_denounced==1
replace violence7_pyear=0 if violence7_pyear==.

gen violence6_pyear=.
replace violence6_pyear=1 if pyear_severe_phy_violence==1 | pyear_weapon_violence==1 |pyear_arson==1 |pyear_graffiti==1 | pyear_theft ==1  |pyear_other_damage==1 |pyear_other_phy_violence==1 | pyear_threat_verbal==1 | pyear_threat_phone==1|pyear_threat_text==1|pyear_threat_mail==1|pyear_threat_email==1|pyear_stalking==1|pyear_threat_gift==1|pyear_threat_other==1|py_attack_social_media==1 | pyear_hijacked_account==1| pyear_online_libel==1 | pyear_poster_pamphlet_libel==1| pyear_undesired_order==1 | pyear_unsolicited_photo_record==1| pyear_falsely_denounced==1
replace violence6_pyear=0 if violence6_pyear==.

gen violence5_pyear=.
replace violence5_pyear=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 |pyear_weapon_violence==1 |pyear_arson==1 |pyear_graffiti==1 | pyear_theft ==1  | pyear_other_phy_violence==1 | pyear_threat_verbal==1 | pyear_threat_phone==1|pyear_threat_text==1|pyear_threat_mail==1|pyear_threat_email==1|pyear_stalking==1|pyear_threat_gift==1|pyear_threat_other==1|py_attack_social_media==1 | pyear_hijacked_account==1| pyear_online_libel==1 | pyear_poster_pamphlet_libel==1| pyear_undesired_order==1 | pyear_unsolicited_photo_record==1| pyear_falsely_denounced==1
replace violence5_pyear=0 if violence5_pyear==.

gen violence4_pyear=.
replace violence4_pyear=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 |pyear_weapon_violence==1 |pyear_arson==1 |pyear_graffiti==1 | pyear_theft ==1  |pyear_other_damage==1 |pyear_other_phy_violence==1 | pyear_threat_verbal==1 | pyear_threat_phone==1|pyear_threat_mail==1|pyear_threat_email==1|pyear_stalking==1|pyear_threat_gift==1|pyear_threat_other==1|py_attack_social_media==1 | pyear_hijacked_account==1| pyear_online_libel==1 | pyear_poster_pamphlet_libel==1| pyear_undesired_order==1 | pyear_unsolicited_photo_record==1| pyear_falsely_denounced==1
replace violence4_pyear=0 if violence4_pyear==.

gen violence2_pyear=.
replace violence2_pyear=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 |pyear_weapon_violence==1 |pyear_arson==1 |pyear_graffiti==1 | pyear_theft ==1  |pyear_other_damage==1 |pyear_other_phy_violence==1 | pyear_threat_verbal==1 | pyear_threat_phone==1|pyear_threat_text==1|pyear_threat_mail==1|pyear_threat_email==1 | pyear_threat_gift==1|pyear_threat_other==1|py_attack_social_media==1 | pyear_hijacked_account==1| pyear_online_libel==1 | pyear_poster_pamphlet_libel==1| pyear_undesired_order==1 | pyear_unsolicited_photo_record==1| pyear_falsely_denounced==1
replace violence2_pyear=0 if violence2_pyear==.

gen violence3_pyear=.
replace violence3_pyear=1 if pyear_severe_phy_violence==1 | pyear_moderate_phy_violence==1 |pyear_weapon_violence==1 |pyear_arson==1 |pyear_graffiti==1 | pyear_theft ==1  |pyear_other_damage==1 |pyear_other_phy_violence==1 | pyear_threat_verbal==1 | pyear_threat_phone==1|pyear_threat_text==1|pyear_threat_email==1|pyear_stalking==1|pyear_threat_gift==1|pyear_threat_other==1|py_attack_social_media==1 | pyear_hijacked_account==1| pyear_online_libel==1 | pyear_poster_pamphlet_libel==1| pyear_undesired_order==1 | pyear_unsolicited_photo_record==1| pyear_falsely_denounced==1
replace violence3_pyear=0 if violence3_pyear==.

*	EQ 2 Excluding one violence form at a time

* 1. excluding stalking
xi:areg violence2_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
* 2. excluding threat_mail
xi:areg violence3 c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
* 3. excluding pyear_threat_text
xi:areg violence4 c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
* 4. excluding pyear_other_damage
xi:areg violence5 c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
* 5. excluding pyear_moderate_phy_violence
xi:areg violence6 c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
* 6. excluding threat_other
xi:areg violence7 c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
* 7. excluding pyear_unsolicited_photo_record
xi:areg violence8 c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
* 8. excluding pyear_online_libel
xi:areg violence9 c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
* 9. excluding py_attack_social_media
xi:areg violence21 c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
* 10. excluding pyear_threat_email
xi:areg violence22 c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
* 11. excluding pyear_threat_phone
xi:areg violence23 c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)
* 12. excluding pyear_threat_verbal
xi:areg violence24 c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommun_level) cluster(kommunkod)

* LOGIT ESTIMATIONS

* Logit estimation of Equation 1
logit violence_pyear female, cl(kommunkod)
xi:logit violence_p female i.party, cl(kommunkod)
xi:logit violence_p female i.party i.year, cl(kommunkod)

* Logit estimation of Equation 2
logit violence_p c.female##c.l_chair c.female##c.l_mayor, cluster(kommunkod)
xi:logit violence_p c.female##c.l_chair c.female##c.l_mayor ///
i.party*l_chair i.party*l_mayor, cluster(kommunkod)
xi:logit violence_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, cluster(kommunkod)

* Standard errors clustered at other levels
* 1. Equation 2, clustered standard errors at party
xi:areg violence_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommunkod) cluster(party)

*2. Equation 2, Cluster std errors at party and municipality
egen party_municipality=group(party kommunkod)
xi:areg violence_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(kommunkod) cluster(party_municipality)

* ////////////////////////////
* // HETEROGENEITY ANALYSES //
* ////////////////////////////

* 2. Majority and opposition

* mayors excluded in all analyses since mayors are only found in the majority
* A. MAJORITY
reg violence_p female if maj==1 & l_m!=1, cluster(kommunkod)
xi:reg violence_p female i.party if maj==1 & l_m!=1, cluster(kommunkod)
xi:reg violence_p female i.party i.year if maj==1 & l_m!=1, cluster(kommunkod)
xi:areg violence_p female i.party i.year if maj==1 & l_m!=1, abs(kommunkod) cluster(kommunkod)

* B. OPPOSITION
reg violence_p female if maj==0 & l_m!=1, cluster(kommunkod)
xi:reg violence_p female i.party if maj==0 & l_m!=1, cluster(kommunkod)
xi:reg violence_p female i.party i.year if maj==0 & l_m!=1, cluster(kommunkod)
xi:areg violence_p female i.party i.year if maj==0 & l_m!=1, abs(kommunkod) cluster(kommunkod)

* 3. Left and right political block

* Eqation 1
* A. LEFT
reg violence_p female if left_wing==1, cluster(kommunkod)
xi:reg violence_p female i.party if left_wing==1, cluster(kommunkod)
xi:reg violence_p female i.party i.year if left_wing==1, cluster(kommunkod)
xi:areg violence_p female i.party i.year if left_wing==1, abs(kommun_level) cluster(kommunkod)
* B. RIGHT
reg violence_p female if right_wing==1, cluster(kommunkod)
xi:reg violence_p female i.party if right_wing==1, cluster(kommunkod)
xi:reg violence_p female i.party i.year if right_wing==1, cluster(kommunkod)
xi:areg violence_p female i.party i.year if right_wing==1, abs(kommun_level) cluster(kommunkod)

* Equation 2
* A. LEFT
reg violence_p c.female##c.l_chair c.female##c.l_mayor if left_wing==1, cluster(kommunkod)
xi:reg violence_p c.female##c.l_chair c.female##c.l_mayor ///
i.party*l_chair i.party*l_mayor if left_wing==1, cluster(kommunkod)
xi:reg violence_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor if left_wing==1, cluster(kommunkod)
xi:areg violence_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor if left_wing==1, abs(kommun_level) cluster(kommunkod)
* B. RIGHT
reg violence_p c.female##c.l_chair c.female##c.l_mayor if right_wing==1, cluster(kommunkod)
xi:reg violence_p c.female##c.l_chair c.female##c.l_mayor ///
i.party*l_chair i.party*l_mayor if right_wing==1, cluster(kommunkod)
xi:reg violence_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor if right_wing==1, cluster(kommunkod)
xi:areg violence_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor if right_wing==1, abs(kommun_level) cluster(kommunkod)

* ////////////////////////
* //     MECHANISMS     //
* ////////////////////////

* 1. Media visibility

tab media_attantion
* "How much media attention do you receive?"
* 5: a lot
* 4: quite a lot
* 3: quite little
* 2: very little 
* 1: none

* Estimates per level of power for those who receive a lot or quite a lot of media attention:
xi:areg violence female i.party i.year if l_m==1 & media==5 | media==4, abs(kommun_level) cl(kommunkod)
xi:areg violence female i.party i.year if l_c==1 & media==5 | media==4, abs(kommun_level) cl(kommunkod)
xi:areg violence female i.party i.year if l_r==1 & media==5 | media==4, abs(kommun_level) cl(kommunkod)

* Estimates per level of power for those who receive quite little, very little or no 
* media attention:
xi:areg violence female i.party i.year if l_m==1 & media==3 | media==2 | media==1, abs(kommun_level) cl(kommunkod)
xi:areg violence female i.party i.year if l_c==1 & media==3 | media==2 | media==1, abs(kommun_level) cl(kommunkod)
xi:areg violence female i.party i.year if l_r==1 & media==3 | media==2 | media==1, abs(kommun_level) cl(kommunkod)

* 2. Portfolios: Sensitivity to excluding specific committee

* Excluding health
xi:areg violence c.female##c.l_chair i.party*l_chair ///
i.year*l_chair if health==0 & l_m==0, abs(kommunkod) cluster(kommunkod)
* Excluding culture leisure
xi:areg violence c.female##c.l_chair i.party*l_chair ///
i.year*l_chair if cult==0 & l_m==0, abs(kommunkod) cluster(kommunkod)
* Excluding planning and building
xi:areg violence c.female##c.l_chair i.party*l_chair ///
i.year*l_chair if plan==0 & l_m==0, abs(kommunkod) cluster(kommunkod)
* Excluding social and family
xi:areg violence c.female##c.l_chair i.party*l_chair ///
i.year*l_chair if soc==0 & l_m==0, abs(kommunkod) cluster(kommunkod)
* Excluding technical
xi:areg violence c.female##c.l_chair i.party*l_chair ///
i.year*l_chair if tec==0 & l_m==0, abs(kommunkod) cluster(kommunkod)
* Excluding other committees
xi:areg violence c.female##c.l_chair i.party*l_chair ///
i.year*l_chair if oth==0 & l_m==0, abs(kommunkod) cluster(kommunkod)

* 3. Intersectional identities

* AGE
* Eq1
xi:areg violence_p female i.party ///
i.year if young==1, abs(kommunkod) cluster(kommunkod)
xi:areg violence_p female i.party ///
i.year if young==0, abs(kommunkod) cluster(kommunkod)

* Eq2
xi:areg violence_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor if young==1, abs(kommun_level) cluster(kommunkod)
xi:areg violence_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor if young==0, abs(kommun_level) cluster(kommunkod)

* SPLIT SAMPLES PER LEVEL OF POWER
xi:areg violence_p female i.party i.year if young==0 & l_r==1, abs(kommunkod) cluster(kommunkod)
xi:areg violence_p female i.party i.year if young==1 & l_r==1, abs(kommunkod) cluster(kommunkod)
xi:areg violence_p female i.party i.year if young==0 & l_c==1, abs(kommunkod) cluster(kommunkod)
xi:areg violence_p female i.party i.year if young==1 & l_c==1, abs(kommunkod) cluster(kommunkod)
xi:areg violence_p female i.party i.year if young==0 & l_m==1, abs(kommunkod) cluster(kommunkod)
xi:areg violence_p female i.party i.year if young==1 & l_m==1, abs(kommunkod) cluster(kommunkod)

* Foreign background

*EQ1
xi:areg violence_p female i.party ///
i.year if foreign_back==0, abs(kommunkod) cluster(kommunkod)

xi:areg violence_p female i.party ///
i.year if foreign_back==1, abs(kommunkod) cluster(kommunkod)

* EQ2
xi:areg violence_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor if foreign_back==0, abs(kommun_level) cluster(kommunkod)
outreg2 using genderethn_table1, dec(3) se excel slow(1500) replace

xi:areg violence_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor if foreign_back==1, abs(kommun_level) cluster(kommunkod)
outreg2 using genderethn_table1, dec(3) se excel slow(1500) append

* SPLIT SAMPLES PER LEVEL OF POWER
xi:areg violence_p female i.party i.year if foreign_back==0 & l_r==1, abs(kommunkod) cluster(kommunkod)
xi:areg violence_p female i.party i.year if foreign_back==1 & l_r==1, abs(kommunkod) cluster(kommunkod)
xi:areg violence_p female i.party i.year if foreign_back==0 & l_c==1, abs(kommunkod) cluster(kommunkod)
xi:areg violence_p female i.party i.year if foreign_back==1 & l_c==1, abs(kommunkod) cluster(kommunkod)
xi:areg violence_p female i.party i.year if foreign_back==0 & l_m==1, abs(kommunkod) cluster(kommunkod)
xi:areg violence_p female i.party i.year if foreign_back==1 & l_m==1, abs(kommunkod) cluster(kommunkod)

* 4. Historical exposure to female mayors

* Identify cut-off point:
sum mean_wmayor, detail

* Generate variable using media as cut-off point:
gen median_low_wmayor = 1 if mean_wmayor < .1875
gen median_high_wmayor = 1 if mean_wmayor >.1875

* SPLIT SAMPLES PER LEVEL OF POWER
* High exposure (over median)
xi:areg violence_p female ///
i.party i.year if median_high_wmayor==1 & l_rankfile==1, abs(kommun_level) cluster(kommunkod)
xi:areg violence_p female ///
i.party i.year if median_high_wmayor==1 & l_c==1, abs(kommun_level) cluster(kommunkod)
xi:areg violence_p female ///
i.party i.year if median_high_wmayor==1 & l_m==1, abs(kommun_level) cluster(kommunkod)

* Low exposure (below median)
xi:areg violence_p female ///
i.party i.year if median_low_wmayor==1 & l_rankfile==1, abs(kommun_level) cluster(kommunkod)
xi:areg violence_p female ///
i.party i.year if median_low_wmayor==1 & l_c==1, abs(kommun_level) cluster(kommunkod)
xi:areg violence_p female ///
i.party i.year if median_low_wmayor==1 & l_m==1, abs(kommun_level) cluster(kommunkod)

* Equation 1 with FE for historical exposure to female mayors per municipality
xi:areg violence_p female i.party i.year, abs(mean_wmayor_level) cluster(kommunkod)

* Equation 2 with FE for historical exposure to female mayors per municipality
xi:areg violence_p c.female##c.l_chair c.female##c.l_mayor i.party*l_chair ///
i.party*l_mayor i.year*l_chair i.year*l_mayor, abs(mean_wmayor_level) cluster(kommunkod)








*******************************************************************************************************************
*******************************************************************************************************************

* ////////////////////////////
* // 		KOLFU DATA 		//
* ////////////////////////////


/* In order to obtain access to the full data set, see https://snd.gu.se/en/catalogue/study/snd1040
Some variables are excluded in the replication file in order to protect
individuals' integrity. These variables are asterisked out in the analyses.
*/


*******************************************************************************************************************
*******************************************************************************************************************


*******************************************************************************************************************
*******************************************************************************************************************

*		KOLFU 2012
*		CODE RELEVANT VARIABLES

*******************************************************************************************************************
*******************************************************************************************************************

use KOLFU 2012.dta

********************* POSITION OF THE POLITICIAN ********************************

* Chair
gen chair=1 if Q13_1==1 | Q13_2==1 | Q13_3==1 | Q13_4==1 | Q13_5==1 | Q13_6==1 | ///
Q13_7==1 | Q13_8==1 | Q13_9==1 | q13_10==1
replace chair=0 if chair==.

* Mayor
generate mayor = Q11_2
replace mayor = 0 if mayor==.
replace mayor = 0 if mayor==.a
recode mayor 1=1 2=0 3=0 4=0 0=0
label define mayor 1 "mayor" 0 "others"
label values mayor mayor
	
* Rankfile
gen rankfile = 1 if mayor !=1 & chair!=1
replace rankfile = 0 if rankfile==.

* Level of power
		gen LevelOfPower =.
	replace LevelOfPower = 1 if rankfile ==1
	replace LevelOfPower = 2 if chair ==1
	replace LevelOfPower =3 if mayor ==1

* New mutually exclusive level categories
gen l_rankfile=1 if Level==1
replace l_rankfile=0 if l_rankfile==.
gen l_chair=1 if Level==2
replace l_chair=0 if l_chair==.
gen l_mayor=1 if Level==3
replace l_mayor=0 if l_mayor==.

rename LevelOfPower levelofpower

***************** CENTRAL VARIABLES: FEMALE AND VIOLENCE ***********************

* FEMALE variable to correspond to PTU

generate female = Kon
recode female 1=0 2=1
label define female 1 "women" 0 "men"
label values female female

* violence
generate violence_pyear=0
replace violence_p=1 if Q16==1

gen	threat_verbal =0		
replace	threat_verbal	=1 if	Q17_1==1	
gen	threat_phone	=0		
replace	threat_phone	=1 if	Q17_2==1	
gen	threat_mail_email=0			
replace	threat_mail_email	=1 if	Q17_3==1	
gen	damage=0			
replace	damage	=1 if	Q17_4==1	
gen	physical_violence=0			
replace	physical_violence =1 if	Q17_5==1	
gen	other_violence	=0		
replace	other_violence	=1 if	Q17_6==1	

gen main_physical = 0
replace main_physical =1 if damage==1 | physical_violence==1

gen main_psychological =0
replace main_psychological =1 if threat_verbal==1  | threat_phone==1  | threat_mail_email==1

*********************** SUPPORTING MINORITIES ************************************

*women
gen prop_w = q43_6
recode prop_w 1=0 2=1 3=2 4=3 5=3
*hbt
gen prop_hbt = q43_10
recode prop_hbt 1=0 2=1 3=2 4=3 5=3
*immigrants
gen prop_im = q43_7
recode prop_im 1=0 2=1 3=2 4=3 5=3

* high and low supporters of political minorities
gen minority_rep_high =1 if prop_w==3 | prop_hbt==3 | prop_im==3
gen minority_rep_low=1 if prop_w==0 | prop_hbt==0 | prop_im==0


* Other variables
* rename Kommunnr kommunkod
rename Parti party

*******************************************************************************************************************
*******************************************************************************************************************

*		ANALYSES

*******************************************************************************************************************
*******************************************************************************************************************

* Replications of main equations

* Equation 1
*1. Full equation 1
xi:areg violence_p female i.party, /*abs(kommunkod) cluster(kommunkod)*/

*2. Full equation 2
xi:reg violence_p c.female##c.l_chair c.female##c.l_mayor ///
i.party*l_chair i.party*l_mayor, /*cluster(kommunkod)*/

* ////////////////////////
* //     MECHANISMS     //
* ////////////////////////

* High and low supporters of political minorities

* Eq1: restricted to high minority supporters
xi:areg violence_p female i.party ///
if minority_rep_high==1/*, abs(kommunkod) cluster(kommunkod)*/
* Eq1: restricted to low minority supporters
xi:areg violence_p female i.party ///
if minority_rep_low==1/*, abs(kommunkod) cluster(kommunkod)*/
* Eq2: restricted to high minority supporters
xi:reg violence_p c.female##c.l_chair c.female##c.l_mayor ///
i.party*l_chair i.party*l_mayor if minority_rep_high==1/*, cluster(kommunkod)*/
* Eq2: restricted to low minority supporters
xi:reg violence_p c.female##c.l_chair c.female##c.l_mayor ///
i.party*l_chair i.party*l_mayor if minority_rep_low==1/*, cluster(kommunkod)*/


* Full specification per level of power, except municipality FE for 
* mayors since there are too few observations
xi:areg violence_p female i.party ///
if minority_rep_high==1 &l_r==1 /*, abs(kommunkod) cluster(kommunkod)*/
xi:areg violence_p female i.party ///
if minority_rep_high==1 &l_c==1/*, abs(kommunkod) cluster(kommunkod)*/
xi:reg violence_p female i.party ///
if minority_rep_high==1 &l_m==1/*, cluster(kommunkod)*/
xi:areg violence_p female i.party ///
if minority_rep_low==1/*, abs (kommunkod) cluster(kommunkod)*/
xi:areg violence_p female i.party ///
if minority_rep_low==1 &l_c==1/*, abs (kommunkod) cluster(kommunkod)*/
xi:reg violence_p female i.party ///
if minority_rep_low==1 &l_m==1/*, cluster(kommunkod)*/

* Replicate PTU with ind level controls

* Variables for age, income group and level of education are excluded from 
* the replication data file and hence cannot be replicated in a meaningful way.
* Below are the analyses performed for Table A17:
xi:reg violence female if l_r==1, cl(kommunkod)
xi:reg violence female i.party if l_r==1, cl(kommunkod)
xi:reg violence female i.party i.edu_l i.Q59 young personvald if l_r==1, cl(kommunkod)
xi:reg violence female if l_c==1, cl(kommunkod)
xi:reg violence female i.party if l_c==1, cl(kommunkod)
xi:reg violence female i.party i.edu_l i.Q59 young personvald if l_c==1, cl(kommunkod)
xi:reg violence female if l_m==1, cl(kommunkod)
xi:reg violence female i.party if l_m==1, cl(kommunkod)
xi:reg violence female i.party i.edu_l i.Q59 young personvald if l_m==1, cl(kommunkod)

*******************************************************************************************************************
*******************************************************************************************************************

*		KOLFU 2017
*		CODE RELEVANT VARIABLES

*******************************************************************************************************************
*******************************************************************************************************************

use KOLFU 2017

drop if Q01==2 /* drop county politicians */

****************************** Personality traits *********************************

foreach n in 1 2 3 4 5 6 7 8 9 10 {
	
	gen p50_`n' = q50_`n'
	replace p50_`n'=p50_`n'+1
	*count if q50_`var'==.
	tab p50_`n'
	}

 foreach n in 1 7 3 4 5 {
	recode p50_`n' (4=1) (3=2) (2=3) (1=4)
  }
  *
  
* Big five
gen extraversion = (p50_1+p50_6)/2
gen agreeableness = (p50_2+p50_7)/2
gen conscientiousness = (p50_3+p50_8)/2
gen neuroticism = (p50_4+p50_9)/2
gen openness = (p50_5+p50_10)/2

*************************** FEMALE *******************************

tab v04_kön
	gen female = v04_kön==1



*******************************************************************************************************************
*******************************************************************************************************************

*		ANALYSES

*******************************************************************************************************************
*******************************************************************************************************************
bysort female: sum extraversion agreeableness conscientiousness neuroticism openness

* all politicians
esize twosample extraversion, by(female) all 
esize twosample agreeableness, by(female) all 
esize twosample conscientiousness, by(female) all 
esize twosample neuroticism, by(female) all 
esize twosample openness, by(female) all 

* mayors
esize twosample extraversion if v31_Listplats_1==1, by(female) all 
esize twosample agreeableness if v31_Listplats_1==1, by(female) all 
esize twosample conscientiousness if v31_Listplats_1==1, by(female) all 
esize twosample neuroticism if v31_Listplats_1==1, by(female) all 
esize twosample openness if v31_Listplats_1==1, by(female) all 



